package com.gx.mxbbx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gx.mxbbx.dao.MxbSortMapper;
import com.gx.mxbbx.po.Area;
import com.gx.mxbbx.po.MxbSort;
import com.gx.mxbbx.service.MxbSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.util.List;

@Service
@Transactional
public class MxbSortServiceImpl implements MxbSortService {
    @Autowired
    private MxbSortMapper mxbSortMapper;

    public PageInfo<MxbSort> getMxbSortList(String sortName, Integer currentPage, Integer limit) {
        PageHelper.startPage(currentPage, limit);
        List<MxbSort> list = mxbSortMapper.getMxbSortList(sortName);
        PageInfo<MxbSort> pageInfo = new PageInfo<MxbSort>(list);
        return pageInfo;
    }

    public void mxbsortadd(MxbSort mxbSort) {
        mxbSort.setCreateTime(new Timestamp(System.currentTimeMillis()));
        mxbSort.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        mxbSortMapper.mxbsortadd(mxbSort);

    }

    public void mxbsortadddelete(Integer id) {
        mxbSortMapper.mxbsortadddelete(id);
    }


    public MxbSort openmxbsortEdit(Integer id) {
        MxbSort mxbSort = mxbSortMapper.openmxbsortEdit(id);
        return mxbSort;
    }

    public void mxbsortedit(MxbSort mxbSort) {
        mxbSort.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        mxbSortMapper.mxbsortedit(mxbSort);
    }
}
